import type { BasicFetchResult, BasicPageParams, BasicRecord } from '/@/api/model/baseModel';
import type { UserInfo } from '/#/store';

// 文章
export type ArticleRecord = BasicRecord & {
  // @Column({ comment: '标题' })
  title: string;
  // @Column({ comment: '内容', type: 'text' })
  content: string;
  // @Column({ comment: '列表内容', type: 'text',nullable:true })
  brief?: string;
  // @Column({ comment: '标签' })
  tag_id: string;
  // @Column({ comment: '栏目' })
  column_id: number;
  // @Column({ comment: '专栏id',nullable:true })
  sp_column_id?: number;
  // @Column({ comment: '用户id' })
  user_id?: number;
  // @Column({ comment: '封面图', nullable: true })
  cover?: string;
  // @Column({ comment: '点赞数', default: 0, nullable: true })
  likes?: number;
  // @Column({ comment: '阅读数', default: 0, nullable: true })
  read?: number;
  // @Column({ comment: '收藏数', default: 0, nullable: true })
  favorites?: number;
  /** 0 已发布文章 1 草稿箱 */
  state?: number;
  /** 0 已发布 1 已下架 2 待更新 3 草稿箱 */
  type?: number;
  user_icon: string;
  user_name: string;
  tag: string;
};

export type ArticlePageParams = BasicPageParams & Partial<Pick<ArticleRecord, 'column_id'>>;

export type ArticlePageResult = BasicFetchResult<ArticleRecord>;

// 栏目
export type ColumnRecord = BasicRecord & {
  icon: string;
  name: string;
};

export type ColumnListParams = Pick<ColumnRecord, 'name'>;

export type ColumnListResult = ColumnRecord[];

// 专栏
export type SpColumnRecord = BasicRecord & {
  article_num: number;
  column_id: number;
  /** 头像 */
  cover: string;
  /** 描述 */
  desc: string;
  /** 名称 */
  name: string;
  subscribe_num: number;
  user_id: number;
};

export type SpColumnPageParams = BasicPageParams & {
  sorts: string;
};

export type SpColumnPageResult = BasicFetchResult<SpColumnRecord>;

export type CommentRecord = BasicRecord & {
  /** 内容 */
  content: string;
  /** 点赞量 */
  star: number;
  /** 文章 id */
  article_id: number;
  /** 评论人 id */
  user_id: number;
  /** 被评论的评论 id, 如果不是回复消息, 那么这个字段为 0 */
  to_comment_id: number;
  /** 被评论用户 id, 默认是沸点作者 */
  to_user_id: number;

  user_icon: string;
  user_name: UserInfo;
  user_desc: string;
  reply_list: Partial<CommentRecord>[];
  to_user_name: UserInfo;
  /** 多级评论需传递顶层评论的 id */
  top_id: number;

  image: string;
  stared: boolean;
  to_comment_content: string;
};

export interface ArticleCommentListParams {
  article_id: number;
  ord?: number;
}

export type ArticleCommentListResult = CommentRecord[];
